package com.hazardSoft.eStore.integration;

import java.util.List;

import com.hazardSoft.eStore.common.exception.SystemException;
import com.hazardSoft.eStore.common.integration.EJB3ServiceLocator;
import com.hazardSoft.eStore.ejb.ListEJB;
import com.hazardSoft.eStore.entities.Brand;
import com.hazardSoft.eStore.entities.Category;
import com.hazardSoft.eStore.entities.City;
import com.hazardSoft.eStore.entities.Department;
import com.hazardSoft.eStore.entities.OfferType;
import com.hazardSoft.eStore.entities.Role;
import com.hazardSoft.eStore.interfaces.ListLocal;
import com.hazardSoft.eStore.utils.PathConstants;

public class ListDelegate {

	private static final String CLASS_NAME = PathConstants.DELEGATES_PATH+ListDelegate.class.getSimpleName();
	private ListLocal listLocal;
	
	public ListDelegate() throws SystemException{
		try {
			listLocal = (ListLocal) EJB3ServiceLocator.getLocalEJB(ListEJB.EJB_NAME);
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "ListDelegate");
		}
	}
	
	public List<Category> listCategories() throws SystemException {
		
		try {
			return listLocal.listCategories();
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "listCategories");
		}
    }
	
	public List<Department> listDepartments() throws SystemException {
	
		try {
			return listLocal.listDepartments();
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "listDepartments");
		}
	}
	
	public List<City> listCities()throws SystemException {		
		
		try {
			return listLocal.listCities();
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "listCities");
		}
	}
	
	public List<City> listCitiesByDepartment(Department department) throws SystemException {		
		
		try {
			return listLocal.listCitiesByDepartment(department);
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "listCitiesByDepartment");
		}
	}

	public List<OfferType> listOfferTypes()throws SystemException {
		
		try {
			return listLocal.listOfferTypes();
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "listOfferTypes");
		}
	}
	
	public List<Role> listRoles()throws SystemException {
		
		try {
			return listLocal.listRoles();
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "listRoles");
		}
	}
	
	public List<Brand> listBrands() throws SystemException {
		
		try {
			return listLocal.listBrands();
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "listBrands");
		}
	}
	
}
